﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// users 的摘要说明
/// </summary>
/*public class users
{
	public users()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
}*/
public class users : SQLHelper
{
    private string _id;
    private string _id1;
    private string _password;
    private string _name;
    private string _sex;
    private string _birthday;
    private string _cadre;
    private string _todate;
    private string _price;
    private string _prodate;
    private string _num;
    private string _descn;
    private string _proid;
    private string _total;
    private string _buydate;
    private string _add;
    private string _phone;
    public string id
    {
        get { return _id; }
        set { _id = value; }
    }
    public string add
    {
        get { return _add; }
        set { _add = value; }
    }
    public string phone
    {
        get { return _phone; }
        set { _phone = value; }
    }
    public string id1
    {
        get { return _id1; }
        set { _id1 = value; }
    }
    public string total
    {
        get { return _total; }
        set { _total = value; }
    }
    public string buydate
    {
        get { return _buydate; }
        set { _buydate= value; }
    }

    public string todate
    {
        get { return _todate; }
        set { _todate = value; }
    }
    public string prodate
    {
        get { return _prodate; }
        set { _prodate = value; }
    }
    public string price
    {
        get { return _price; }
        set { _price = value; }
    }
    public string num
    {
        get { return _num; }
        set { _num = value; }
    }
    public string descn
    {
        get { return _descn; }
        set { _descn = value; }
    }
    public string proid
    {
        get { return _proid; }
        set { _proid = value; }
    }
    public string ps
    {
        get { return _password; }
        set { _password = value; }
    }
    public string name
    {
        get { return _name; }
        set { _name = value; }
    }
    public string cadre
    {
        get { return _cadre; }
        set { _cadre = value; }
    }
    public string sex
    {
        get { return _sex; }
        set { _sex = value; }
    }
    public string birthday
    {
        get { return _birthday; }
        set { _birthday = value; }
    }
    public users()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }
    ///查找ID是否重复
    public int isExist(users tmp)
    {
        //users us = new users();
        string sql = "select count(*) from UserInfo where UserID='" + tmp._id + "'";
        int result = 0;
        result = tmp.ExeScalar(sql);
        return result;
    }
    //登录
    public int login(users tmp)
    {
        string sql = "select count(*) from UserInfo where UserID='" + tmp._id + "'and UserPW='" + tmp._password + "'";
        int result = 0;
        result = tmp.ExeScalar(sql);
        return result;

    }
    public int register(users tmp)
    {
        string sql = "select count(*) from UserInfo where UserName='" + tmp._name + "' and UserID='" + tmp._id + "'and UserPW='" + tmp._password + "'and UserBirthday='" + tmp._birthday + "'and UserSex='" + tmp._sex + "'  and UserStyle='" + tmp._cadre + "' ";
        int result = 0;
        result = tmp.ExeScalar(sql);
        return result;

    }
    /*  public int update(users tmp)
    {
        string sql = "update  StudentInfo set Spassword='" + ps + "',Sname='" + name + "',Sbirthday='" + birthday + "',Sclas='" + clas + "',Ssex='" + sex + "'Scadre='" + cadre + "',where Sid='" + id + "')";
        int result = 0;
        result = tmp.ExeScalar(sql);
        return result;
    }*/

    /*  public int submit(users tmp)
      {
          string sql = "insert into user_1(u_ID, u_password)  values('" + tmp.id + "','" + tmp.ps + "')";
          int result = 0;
          result = tmp.getExecuteNonQuery(sql);
          return result;
      }*/
    public int delete(users tmp)
    {
        string sql = "delete from MerchInfo where MerchID='" + tmp.id + "'";
        int result = 0;
        result = tmp.ExeNonQuery(sql);
        return result;
    }
    public int delete1(users tmp)
    {
        string sql = "delete from StockInfo where StockID='" + tmp.id + "'";
        int result = 0;
        result = tmp.ExeNonQuery(sql);
        return result;
    }
    public int delete2(users tmp)
    {
        string sql = "delete from SaleInfo where SaleID='" + tmp.id + "'";
        int result = 0;
        result = tmp.ExeNonQuery(sql);
        return result;
    }
    public int delete3(users tmp)
    {
        string sql = "delete from UserInfo where UserID='" + tmp.id + "'";
        int result = 0;
        result = tmp.ExeNonQuery(sql);
        return result;
    }
    public int delete4(users tmp)
    {
        string sql = "delete from ProvideInfo where ProvideID='" + tmp.id + "'";
        int result = 0;
        result = tmp.ExeNonQuery(sql);
        return result;
    }
    /*public int rivise(users tmp)
    {
        string sql = "update user_1 set u_password='" + tmp.ps + "' where u_ID='" + tmp.id + "'";
        int result = 0;
        result = tmp.getExecuteNonQuery(sql);
        return result;
    }

    public int check(users tmp)
    {
        string sql = "select count(*) from user_1 where u_password='" + tmp.ps + "' and u_ID='" + tmp.id + "'";
        int result = 0;
        result = tmp.getExecuteScalar(sql);
        return result;
    }*/
    public DataSet GetAllUsers(users us)
    {
        string sql = "select * from StockInfo ";
        users tmp = new users();
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }
    public DataSet GetAllUsers1(users us)
    {
        string sql = "select * from MerchInfo ";
        users tmp = new users();
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }
    public DataSet GetAllUsers2(users us)
    {
        string sql = "select * from SaleInfo ";
        users tmp = new users();
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }
    public DataSet GetAllUsers3(users us)
    {
        string sql = "select * from UserInfo ";
        users tmp = new users();
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }
    public DataSet GetAllUsers4(users us)
    {
        string sql = "select * from KucunInfo ";
        users tmp = new users();
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }
    public DataSet GetAllUsers5(users us)
    {
        string sql = "select * from ProvideInfo ";
        users tmp = new users();
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }
    public DataSet GetOneUsers(users tmp)
    {
        string sql = "select * from UserInfo where UserID='" + tmp.id + "'OR UserName='" + tmp.name + "'";
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }
    public DataSet GetOneUsers1(users tmp)
    {
        string sql = "select * from MerchInfo where MerchID='" + tmp.id + "'OR MerchName='" + tmp.name + "'"; 
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }
    public DataSet GetOneUsers2(users tmp)
    {
        string sql = "select * from StockInfo where StockID='" + tmp.id + "'OR MerchId='" + tmp.id1 + "'";
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }
    public DataSet GetOneUsers3(users tmp)
    {
        string sql = "select * from SaleInfo where SaleID='" + tmp.id + "'OR MerchId='" + tmp.id1 + "'";
        DataSet ds = tmp.GetDs(sql);
        return ds;

    }

    public  int Updateoneuser (users tmp)
      {
          string sql = "update  MerchInfo set MerchID='" + tmp.id +
              "',MerchName='" + tmp.name +
             "',MerchPrice='" + tmp.price +
             "',MerchDescn='" + tmp.descn +
             "',MerchNum='" + tmp.num +
             "', ProvideID='" + tmp.proid +
              "',BeginDate='" + tmp.prodate +
              "',ToDate='" + tmp.todate +
              "' where MerchID='" + id + "'";
          int result = tmp.ExeNonQuery (sql);
          return result;
      }
     public int Updateoneuser1(users tmp)
     {
         string sql = "update  StockInfo set StockID='" + tmp.id +
             "',MerchID='" + tmp.id1 +
             "',MerchName='" + tmp.name +
             "',MerchDescn='" + tmp.descn +
              "', ProvideID='" + tmp.proid +
               "',MerchPrice='" + tmp.price +
             "',MerchNum='" + tmp.num +
             "',MerchSumP='" + tmp.total +
             "',StockDate='" + tmp.buydate +
             "'where StockID='" + id + "'";
         int result = tmp.ExeNonQuery(sql);
         return result;
     }
     public int Updateoneuser2(users tmp)
     {
         string sql = "update  SaleInfo set SaleID='" + tmp.id +
             "',MerchID='" + tmp.id1 +
             "',MerchName='" + tmp.name +
               "',SalePrice='" + tmp.price +
             "',SaleNum='" + tmp.num +
             "'where SaleID='" + id + "'";
         int result = tmp.ExeNonQuery(sql);
         return result;
     }
     public int Updateoneuser3(users tmp)
     {
         string sql = "update  UserInfo set UserID='" + tmp.id +
             "',UserName='" + tmp.name +
             "',UserPW='" + tmp.ps +
               "',UserSex='" + tmp.sex +
             "',UserBirthday='" + tmp.birthday +
             "'where UserID='" + id + "'";
         int result = tmp.ExeNonQuery(sql);
         return result;
     }
     public int Updateoneuser4(users tmp)
     {
         string sql = "update  ProvideInfo set ProvideID='" + tmp.id +
             "',ProvideName='" + tmp.name +
             "',ProvideAdd='" + tmp.add +
               "',ProvidePhone='" + tmp.phone +
             "'where ProvideID='" + id + "'";
         int result = tmp.ExeNonQuery(sql);
         return result;
     }
    /* public int Deleteoneuser(users tmp)
     {
         string sql = "delete from message where u_ID='" + tmp.id + "'";
         int result = tmp.ExeNonQuery(sql);
         return result;
     }*/
    public SqlDataReader GetOneUserRead(users tmp)
    {
        string sql = "select * from UserInfo  where UserID='" + tmp.id + "'";
        SqlDataReader rd = tmp.ExeReader(sql);
        return rd;
    }
}
